#include "cpu/exec/template-start.h"
    

/*******************************************/
#define instr je

static void do_execute(){
    int32_t dis = op_src -> val;
    if(cpu.eflags.ZF == 1){
        cpu.eip += dis;
        //printf("%d\n",op_src->val);
    }
    print_asm("je  $0x%x", cpu.eip + 1 + DATA_BYTE);
    //print_asm("%d",dis);
}

make_instr_helper(si)

#undef instr
/*******************************************/

#define instr jbe
static void do_execute(){
    DATA_TYPE_S dis = op_src->val;
    if(cpu.eflags.CF == 1 || cpu.eflags.ZF  == 1){
        cpu.eip += dis;
        print_asm("jbe $0x%x",cpu.eip + 1 + DATA_BYTE);
    }
    else print_asm("notjbe $0x%x",cpu.eip + 1 + DATA_BYTE);
}

make_instr_helper(si)
#undef instr

/*******************************************/
#define instr jne

static void do_execute(){
    int32_t dis = op_src->val;
    if(cpu.eflags.ZF == 0){
        cpu.eip += dis;
        print_asm("jne 0x%x",cpu.eip + 1 + DATA_BYTE);
    }
    // else{
    //     printf(" here 0x%x\n",cpu.eip + 1 + DATA_BYTE);
    // }
    else print_asm("notjne $0x%x",cpu.eip + 1 + DATA_BYTE);
}

make_instr_helper(si)
#undef instr
/*****************************************/

#define instr jle

static void do_execute(){
    int32_t dis = op_src->val;
    if(cpu.eflags.ZF == 1 || (cpu.eflags.SF != cpu.eflags.OF))
        cpu.eip += dis;
    print_asm("jle $0x%x",cpu.eip + 1 + DATA_BYTE);
}
make_instr_helper(si)
#undef instr
/*******************************************/

#define instr jg
static void do_execute(){
    int32_t dis = op_src->val;
    if((cpu.eflags.OF == cpu.eflags.SF) && cpu.eflags.ZF == 0)
        cpu.eip += dis;
    print_asm("jg $0x%x",cpu.eip + 1 + DATA_BYTE);
}
make_instr_helper(si)
#undef instr
/*************************************/

#define instr jl
static void do_execute(){
    DATA_TYPE_S dis = op_src->val;
    if(cpu.eflags.ZF == 0 && (cpu.eflags.SF != cpu.eflags.OF)){
        cpu.eip += dis;
        print_asm("jl $0x%x",cpu.eip + 1 + DATA_BYTE);
    }
    else print_asm("notjl $0x%x",cpu.eip + 1 + DATA_BYTE);

}
make_instr_helper(si)
#undef instr
/**************************************/

#define instr jge
static void do_execute(){
    int32_t dis = op_src->val;
    if((cpu.eflags.OF == cpu.eflags.SF) || cpu.eflags.ZF == 1)
        cpu.eip += dis;
    print_asm("jge $0x%x",cpu.eip + 1 + DATA_BYTE);
}

make_instr_helper(si)
#undef instr
/*****************************************/

#define instr ja
static void do_execute(){
    int dis = op_src->val;
    if(cpu.eflags.ZF == 0 && cpu.eflags.CF == 0)
        cpu.eip += dis;
    print_asm("ja $0x%x",cpu.eip + 1 + DATA_BYTE);
}
make_instr_helper(si)
#undef instr
/***********************************************/

#define instr js
static void do_execute(){
    int dis = op_src->val;
    if(cpu.eflags.SF == 1){
        cpu.eip += dis;
    }
    print_asm("js $0x%x",cpu.eip + 1 + DATA_BYTE);
}
make_instr_helper(si)
#undef instr
/***********************************************/

#define instr jns
static void do_execute(){
    int dis = op_src->val;
    if(cpu.eflags.SF == 0){
        cpu.eip += dis;
    }
    print_asm("js $0x%x",cpu.eip + 1 + DATA_BYTE);
}
make_instr_helper(si)
#undef instr


#include "cpu/exec/template-end.h"